<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
  <div id="root"></div>
  <script>
    
    const app = Vue.createApp({
      data(){
        return{
          number:1,
          animateNumber:1
        }
      },
      methods:{
        click(){
          this.number=10;
          if(this.animateNumber<this.number){
            const animation=setInterval(()=>{
              this.animateNumber+=1;
              if(this.animateNumber===10){
                clearInterval(animation)
              }
            },1000)
          }
        }
      },
      template:`<div>{{animateNumber}}</div><button @click="click">增加</button>`
    });
   
    const vm = app.mount('#root');
  </script>
</body>

</html>